using UnityEngine;

namespace Delta2DGame.Base
{
    /// <summary>
    /// 角色状态基类
    /// </summary>
    public abstract class PlayerState
{
    protected PlayerStateMachine stateMachine;
    protected PlayerController player;
    protected Animator animator;

    protected string animBoolName;
    protected Transform skeletonTransform;

    public PlayerState(PlayerStateMachine stateMachine, PlayerController player, string animBoolName)
    {
        this.stateMachine = stateMachine;
        this.player = player;
        this.animBoolName = animBoolName;
        skeletonTransform = player.transform.Find("PlayerSkeletonAnimation");
        animator = skeletonTransform.GetComponent<Animator>();
    }

    /// <summary>
    /// 进入状态时调用
    /// </summary>
    public virtual void Enter()
    {
        animator.SetBool(animBoolName, true);
    }

    /// <summary>
    /// 每帧更新时调用
    /// </summary>
    public virtual void Update()
    {

    }

    /// <summary>
    /// 物理更新时调用
    /// </summary>
    public virtual void FixedUpdate()
    {

    }

    /// <summary>
    /// 退出状态时调用
    /// </summary>
    public virtual void Exit()
    {
        animator.SetBool(animBoolName, false);
    }
}
}